﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.Data
{
    using InnoWeb.CEND.Core.Model.Blog;
    using InnoWeb.CEND.Core.Model.Expert;
    using InnoWeb.CEND.Core.Model.General;
    using InnoWeb.CEND.Core.Model.iThink;
    using InnoWeb.CEND.Core.Model.News;
    using InnoWeb.CEND.Core.Model.Page;
    using InnoWeb.CEND.Core.Model.Reports;
    using InnoWeb.CEND.Core.Model.Training;
    using InnoWeb.CEND.Core.Model.User;
    using InnoWeb.CEND.Core.Model.Videos;
    using InnoWeb.CEND.Core.Model.Workshop;
    using InnoWeb.CEND.Data.Mapping.Blog;
    using InnoWeb.CEND.Data.Mapping.Expert;
    using InnoWeb.CEND.Data.Mapping.General;
    using InnoWeb.CEND.Data.Mapping.iThink;
    using InnoWeb.CEND.Data.Mapping.News;
    using InnoWeb.CEND.Data.Mapping.Page;
    using InnoWeb.CEND.Data.Mapping.Report;
    using InnoWeb.CEND.Data.Mapping.Training;
    using InnoWeb.CEND.Data.Mapping.User;
    using InnoWeb.CEND.Data.Mapping.Video;
    using InnoWeb.CEND.Data.Mapping.Workshop;

    public class WebSiteContext : DbContext
    {
        public DbSet<BlogComment> BlogComments { get; set; }
        public DbSet<BlogContent> BlogContents{ get; set; }
        public DbSet<BlogItem> BlogItems{ get; set; }

        public DbSet<ExpertInfo> ExpertInfoes{ get; set; }

        public DbSet<AboutPageContents> AboutPageContents { get; set; }
        public DbSet<IndustryPageContent> IndustryPageContents { get; set; }
        public DbSet<MottoItem> MottoItems { get; set; }
        public DbSet<SliderContent> SliderContents { get; set; }
        public DbSet<SolutionPageContent> SolutionPageContents { get; set; }

        public DbSet<iThinkContents> iThinkContents { get; set; }
        public DbSet<iThinkItems> iThinkItems { get; set; }
        public DbSet<iThinkMenuItems> iThinkMenuItems { get; set; }

        public DbSet<NewsContent> NewsContents { get; set; }
        public DbSet<NewsItem> NewsItems { get; set; }

        public DbSet<Category> Categories { get; set; }
        public DbSet<PageContent> PageContents { get; set; }
        public DbSet<PageItem> PageItems { get; set; }

        public DbSet<ReportContent> ReportContents { get; set; }
        public DbSet<ReportItem> ReportItems { get; set; }

        public DbSet<TrainingContent> TrainingContents { get; set; }
        public DbSet<TrainingItem> TrainingItems { get; set; }

        public DbSet<User> Users { get; set; }

        public DbSet<VideoContents> VideoContents { get; set; }

        public DbSet<WorkshopContent> WorkshopContents { get; set; }
        public DbSet<WorkshopItem> WorkshopItems { get; set; }

        public DbSet<ContactInfo> ContactInfoes { get; set; }
        public DbSet<CareerInfo> CareerInfoes { get; set; }

        public WebSiteContext()
            :base()
        {
            this.Configuration.AutoDetectChangesEnabled = false;
            this.Configuration.LazyLoadingEnabled = true;
        }

        public WebSiteContext(string connName)
            :base(connName)
        {
            this.Configuration.AutoDetectChangesEnabled = false;
            this.Configuration.LazyLoadingEnabled = true;
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {

            modelBuilder.Configurations.Add(new BlogCommentMapping());
            modelBuilder.Configurations.Add(new BlogContentMapping());
            modelBuilder.Configurations.Add(new BlogItemMapping());

            modelBuilder.Configurations.Add(new ExpertInfoMapping());

            modelBuilder.Configurations.Add(new AboutPageContentMapping());
            modelBuilder.Configurations.Add(new IndustryPageContentMapping());
            modelBuilder.Configurations.Add(new MottoItemMapping());
            modelBuilder.Configurations.Add(new SliderContentMapping());
            modelBuilder.Configurations.Add(new SolutionPageContentMapping());

            modelBuilder.Configurations.Add(new iThinkContentMapping());
            modelBuilder.Configurations.Add(new iThinkItemMapping());
            modelBuilder.Configurations.Add(new iThinkMenuItemMapping());

            modelBuilder.Configurations.Add(new NewsContentMapping());
            modelBuilder.Configurations.Add(new NewsItemMapping());

            modelBuilder.Configurations.Add(new CategoryMapping());
            modelBuilder.Configurations.Add(new PageContentMapping());
            modelBuilder.Configurations.Add(new PageItemMapping());

            modelBuilder.Configurations.Add(new ReportContentMapping());
            modelBuilder.Configurations.Add(new ReportItemMapping());

            modelBuilder.Configurations.Add(new TrainingContentMapping());
            modelBuilder.Configurations.Add(new TrainingItemMapping());

            modelBuilder.Configurations.Add(new UserMapping());

            modelBuilder.Configurations.Add(new VideoContentMapping());

            modelBuilder.Configurations.Add(new WorkshopContentMapping());
            modelBuilder.Configurations.Add(new WorkshopItemMapping());

            modelBuilder.Configurations.Add(new CareerInfoMapping());
            modelBuilder.Configurations.Add(new ContactInfoMapping());

            base.OnModelCreating(modelBuilder);
        }
    }
}
